package com.lg;

import org.junit.Test;

public class LambdaTest {
    @Test
	public void test01() {
    	MathOperation math = (int a,int b)->a+b;
		System.out.println(math.operation(1, 1));
	}
    @Test
   	public void test02() {
       	MathOperation math = ( a, b)->a+b;
   		System.out.println(math.operation(1, 1));
   	}
    // 大括号中的返回语句
    @Test
    public void test03() {
    	final int c = 10;
     	MathOperation math =(a,b)->{return b * a+a+c;};
     	System.out.println(math.operation(1, 1));
     // 不用括号
     	GreetingService greeting = message -> System.out.println("hello  "+message);
     	greeting.sayMessage("tom");
    }
	interface MathOperation {
		int operation(int a, int b);
	}

	interface GreetingService {
		void sayMessage(String message);
	}

	private int operate(int a, int b, MathOperation mathOperation) {
		return mathOperation.operation(a, b);
	}
}
